<?php 
$msgTypes = array('error', 'message', 'status');
if (count($messages)) { 
	?><ul class="messages"><?php
	foreach ($msgTypes as $type) { 
		if (array_key_exists($type, $messages)) {
			foreach ($messages[$type] as $key => $message) {
				?><li class="<?php echo $type; ?>"><?php echo $message; ?></li><?php
			}
		}
	}
	?></ul><?php 
}
?>